package com.techstar.ats.netty.handler;

import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import com.techstar.ats.ConnectProperties;
import com.techstar.ats.dxp.AtsMessage;

public class LinkLayerHandler extends ChannelDuplexHandler {
	public final ConnectProperties properties;

	public LinkLayerHandler(ConnectProperties properties) {
		this.properties = properties;
	}

	public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
		if(msg instanceof AtsMessage) {
			((AtsMessage) msg).line = this.properties.getLine();
		}

		super.write(ctx, msg, promise);
	}
}
